import { http } from '@/utils/http'

export const wxSimpleLogin = (data: wxSimpleLoginParams) => {
  return http({
    method: 'GET',
    url: 'goods/goodsInfo/wxGetGoodsListBySelectId',
    data,
  })
}

type wxSimpleLoginParams = {
  code: string
  tel: string
}

export const wxTestSimpleLogin = (phone: string) => {
  return http<repUserInfo>({
    method: 'GET',
    url: 'user/user/wxAppLoginByPhone',
    data: { phone },
  })
}
// public String token;
// public String userId;
// private UsUser userInfo;
export type repUserInfo = {
  token: string
  userId: string
  userInfo: userInfoData
  userDetailInfo: userDetailInfoData
}
type userInfoData = {
  id: string
  userName: string
  userPhone: string
  userPassword: string
  userNickname: string
  userIcon: string
  createTime: string
  updateTime: string
  userLevel: number
  userState: number
  userSalt: string
}

type userDetailInfoData = {
  id: string
  createTime: string
  updateTime: string
  userAge: number
  userSex: number
  userIdentityImage: string
  userCreateType: string
  userCreateUserid: string
  userBirthday: string
  userCareer: string
  userCity: string
  userBirthdayStr: string
}
export const wxAppGetwxUserData = () => {
  return http<repWxUserDtosInfo>({
    method: 'GET',
    url: 'user/user/wxAppGetwxUserData',
    data: {},
  })
}
export type repWxUserInfo = {
  userInfo: userInfoData
  userDetailInfo: userDetailInfoData
}

export type repWxUserDtosInfo = {
  userIcon: string
  userName: string
  userNickname: string
  userSex: number
  userBirthdayStr: string
  userCity: string
  userCareer: string
}

export type imgRes = {
  host: string
  code: string
  errorMessage: string
  data: imgResData
}
export type imgResData = {
  host: string
  code: string
  data: string
  errorMessage: string
}
export const updateWxUserData = (data: repWxUserDtosInfo) => {
  return http({
    method: 'POST',
    url: 'user/user/wxAppUpdateWxUser',
    data,
  })
}
